<include file="Public:header" />
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/static/kindeditor/kindeditor-min.js"></script>
<script type="text/javascript">
    <!--
    KindEditor.ready(function(K) {
        var detaileditor;
        detaileditor = K.create('#content', {
            newlineTag : 'br'
        });
    });
    $(function(){
        $.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'200',height:'50'}, function(){this.close();$(obj).focus();})}});
        $("#catid").formValidator({onshow:"请选择商品分类",onfocus:"请选择商品分类",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"请选择商品分类"});
        $("#brand").formValidator({onshow:"请选择商品品牌",onfocus:"请选择商品品牌",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"请选择商品品牌"});
        $("#title").formValidator({onshow:"请输入标题",onfocus:"请输入标题",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"请输入标题"});
        $("#goods_sn").formValidator({onshow:"请输入商品货号",onfocus:"请输入商品货号",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"请输入商品货号"});
        $("#market_price").formValidator({onshow:"请输入市场价格",onfocus:"请输入市场价格",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"请输入市场价格"});
        $("#shop_price").formValidator({onshow:"请输入本店价格",onfocus:"请输入本店价格",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"请输入本店价格"});
        $("#goods_num").formValidator({onshow:"请输入商品库存",onfocus:"请输入商品库存",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"请输入商品库存"});
    })
    function delPic(obj) {
        var src = $('#picurl').val();

        $.get("__APP__?m=Goods&a=delpic&picurl="+src);
        $('#picshow').html('');
        $('#picurl').val('');
    }
    //-->
</script>
<div class="common-form">
    <div style="clear:both;"><a href="{:U('Goods/index')}" class="navbtn">返回{$modulename}管理</a></div>
    <form name="myform" id="myform" action="{:U('Goods/insert')}" method="post">
        <input type="hidden" name="status" value="1">
        <input type="hidden" name="picurl" id="picurl" value="">
        <table width="100%" class="table_form contentWrap">
            <tr>
                <td align="right" width="80">商品名称：</td>
                <td align='left'><input type="text" name="title" id="title" onkeyup="checkLen(this,{$CFG.cell_titlelen},'titlelen');" onchange="checkLen(this,{$CFG.cell_titlelen},'titlelen');" size="30">
                    {:show_style('toptitle')} 不能超过{$CFG.cell_titlelen}个字符，还可以输入 <span id="titlelen" class="red">{$CFG.cell_titlelen}</span> 字
                </td>
            </tr>
            <tr>
                <td align="right" width="80">商品货号：</td>
                <td align='left'><input type="text" name="goods_sn" id="goods_sn" size="30">
                </td>
            </tr>
            <tr>
                <td align="right" width="80">市场售价：</td>
                <td align='left'><input type="text" name="market_price" id="market_price" size="30">

                </td>
            </tr>
            <tr>
                <td align="right" width="80">本店售价：</td>
                <td align='left'><input type="text" name="shop_price" id="shop_price" size="30">

                </td>
            </tr>
            <tr>
                <td align="right" width="80">商品库存：</td>
                <td align='left'><input type="text" name="goods_num" id="goods_num" size="30">

                </td>
            </tr>
            <tr>
                <td align="right" width="100">上传商品图片：</td>
                <td align='left' id="td_txt">
                    <div style="width: 400px;height: 200px;">
                        <div class="waitpic cu" style="width:300px;height:140px;" onclick="if($('#picurl').val()!=''){preview($('#picurl').val());return false;}doDialog('{:U(\'Goods/upload\')}','上传图片','320','100');">
                            <span id="picshow"></span>
                        </div>
                        <div style="width:300px;text-align:center;">
                            <span onclick="doDialog('{:U(\'Goods/upload\')}','上传图片','320','100')" class="cu"><img src="__PUBLIC__/Admin/Images/icon/img_upload.gif" title="上传"/></span>&nbsp;&nbsp;
                            <span onclick="delPic();" class="cu"><img src="__PUBLIC__/Admin/Images/icon/img_delete.gif" width="12" height="12" title="删除"/></span>
                        </div>
                        图片 （图片宽高：<span class="red">200 X 140</span> px，超过此宽度或高度将被自动裁剪。）
                    </div>
                </td>
            </tr>
            <tr>
                <td align="right">商品描述：</td>
                <td align='left'><textarea name='content' id='content' style='height:400px;width:700px;'></textarea></td>
            </tr>
            <tr>
                <td align="right">商品分类：</td>
                <td align='left'>
                    <select name="cat_name" id='catid'>
                        <option value="0" selected>--选择品牌--</option>
                        <volist name="goodsCategory" id="vo">
                            <option value="{$vo.cat_id}">{$vo.cat_name}</option>
                        </volist>
                    </select>
                </td>
            </tr>
            <tr>
                <td align="right">商品品牌：</td>
                <td align='left'>
                    <select name="brand" id='brand'>
                        <option value="0" selected>--选择品牌--</option>
                        <volist name="brand" id="vo">
                            <option value="{$vo.brand_id}">{$vo.brand_name}</option>
                        </volist>
                    </select>
                </td>
            </tr>

            <tr>
                <td align="right"></td>
                <td align='left'><input type="submit" id="dosubmit" class="button" name="dosubmit" value=" 提 交 "/></td>
            </tr>
        </table>
        <div class="bk15"></div>
    </form>
</div>